package com.foxzzz.array;


public class SolutionLCP17 {

    public int calculate(String s) {
        int x = 1, y = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if ('A' == c) {
                x = 2 * x + y;
            } else if ('B' == c) {
                y = 2 * y + x;
            }
        }
        return x + y;
    }

    public static void main(String[] args) {
        System.out.println(new SolutionLCP17().calculate("AB"));
    }
}
